package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import com.itheima.pojo.JobData;
import com.itheima.pojo.OperateLog;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

    List<Emp> list(EmpQueryParam empQueryParam);

    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})") //用于配置插入数据后返回主键
    //useGeneratedKeys:是否使用自动生成的主键值
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void insert(Emp emp);

    void deleteByIds(List<Integer> ids);

    @Select("select * from emp where id=#{id}")
    Emp selectById(Integer id);

    Emp selectInfoById(Integer id);

    void updateById(Emp emp);

    List<JobData> empJobData();

    @MapKey("name")
    List<Map> countEmpGenderData();

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp selectByUsernameAndPassword(Emp emp);

    @Select("select * from emp")
    List<Emp> selectAll();

    @Select("select operate_log.*,e.name as operateEmpName from operate_log left join emp e on operate_emp_id=e.id")
    List<OperateLog> logPage(String operateEmpName, String className, String methodName, Long costTime, String methodParams, String returnValue, LocalDateTime openDateTime);

}
